import { reactive } from "vue";
import { api } from 'boot/axios'
import { CommonApiPrefix } from 'src/common/const'
/**
 * @description 获取用户  推广员等
 * 
 * */
export const useUserList = () => {

  const list = reactive<any[]>([])
  const fetchData = async () => {
    try {
      const res = await api.get(`${CommonApiPrefix}/user/search`, { params: {page: 1, size: 100000} });
      list.push(...res.data.userVOList
        .filter((item: any) => (item.id && item.loginname))
        .map((item: any) => {
        const { id, loginname } = item
        return {
          value: id,
          label: loginname || ''
        }
      }))
    } catch (error) {
      console.log(error);
    }
  }
  fetchData();
  return [list];
};
